require "rubygems"
require "activerecord"

require "wondercap/lib/deployment/model/deployment"
require "wondercap/lib/deployment/model/snapshot"

class AddDeployedAtAttributeToDeployment < ActiveRecord::Migration
  include Wondercap::Deployment
  
  def self.up
    add_column :deployments, :deployed_at, :null => false
    
    Deployment.reset_column_information
    Snapshot.find(:all).each do |snapshot|
      snapshot.each do |deployment|
        deployment.deployed_at = snapshot.created_at
        deployment.save!
      end
    end
  end
  
end